import request from './request'

/**
 * 查询所有菜单树
 */
export const getAllMenuTree = () => {
  return request({
    url: '/menu/tree',
    method: 'get'
  })
}

/**
 * 根据用户ID查询菜单树
 */
export const getMenuTreeByUserId = (userId) => {
  return request({
    url: `/menu/user/${userId}`,
    method: 'get'
  })
}

/**
 * 添加菜单
 */
export const addMenu = (data) => {
  return request({
    url: '/menu/add',
    method: 'post',
    data
  })
}

/**
 * 更新菜单
 */
export const updateMenu = (data) => {
  return request({
    url: '/menu/update',
    method: 'put',
    data
  })
}

/**
 * 删除菜单
 */
export const deleteMenu = (menuId) => {
  return request({
    url: `/menu/delete/${menuId}`,
    method: 'delete'
  })
}